include Java
require 'yaml'
JENV=java.lang.System
LOCAL_REPO=JENV.getProperty('user.home')+"/.m2/repository/" unless Object.const_defined?(:LOCAL_REPO)

class JarsLoader
  def load_jars
    YAML::load(File.open(File.dirname(__FILE__)+'/required_jars.yaml')).each do |jar|
      # we assume that if the file dosn't exists than its located in the local repo
      safe_require(jar)
    end
  end

  def safe_require(jar)
    begin
      require jar
    rescue LoadError => e
      require LOCAL_REPO+jar
    end
  end
end

